<!doctype html>
<html>
<?php echo $this->fetch('head.html'); ?>

<body>
  <div class="fullscreen">
  <div class="scroll_contentx">
    <div class="topfixed">
      <div class="t_left"><a href="/index.php" class="goBack"><i class="back"></i></a></div>
      <div class="t_main" ><?php if ($this->_var['cat']): ?><?php echo $this->_var['cat']['cname']; ?><?php else: ?>全部商家<?php endif; ?></div>
      <div class="t_right"><div class="ico_search" id="cl-search"></div></div>
    </div>
    <div class="paddingheight"></div>
 
     
    
    <div class="search-box" id="search-box">
    	<div class="l">
        	<div class="mn">
        	<input type="text" name="keyword" id="keyword" placeholder="请输入商名称">
            </div>
        </div>
        <div class="r"><button class="btn" type="button" id="search-submit">搜索</button></div>
    </div>
    
    <script>
    
	
	$(document).on("click","#cl-search",function(){
		$("#search-box").toggle();
		 
	});
	 
	$(document).on("click","#search-submit",function(){
		window.location='/index.php?m=shoplist&keyword='+$("#keyword").val();
	});
    </script>
    
     
    <?php $this->_var['orderbys']=array('default'=>"智能排序",'distance'=>'距离最近','sold_num'=>'销量最高','raty_grade'=>'评价最好');;?>
    <?php $this->_var['filters']=array('cspf'=>'超时赔付','isnew'=>'新店');;?>
    <div style="position:relative;">
    <div class="tab-select i4">
    		<div class="item" id="tab-category"><span class="t"><?php if ($this->_var['cat']): ?><?php echo $this->_var['cat']['cname']; ?><?php else: ?>全部商家<?php endif; ?></span> <i class="t3down "></i><b></b></div>
            
            <div class="item" id="tab-scarea"><span class="t"><?php if ($this->_var['scarea']): ?><?php echo $this->_var['scarea']['title']; ?><?php else: ?>区域<?php endif; ?></span> <i class="t3down"></i><b></b></div>
            	
    		<div class="item" id="tab-order"><span class="t"><?php if (get ( 'orderby' )): ?><?php echo $this->_var['orderbys'][get('orderby')]; ?><?php else: ?>智能排序<?php endif; ?></span> <i class="t3down"></i><b></b></div>
    		<div class="item" id="tab-choice"><span class="t"><?php if (get ( 'filter' )): ?><?php echo $this->_var['filters'][get('filter')]; ?><?php else: ?>筛选<?php endif; ?></span> <i class="t3down"></i></div>
    </div>
     
    <div id="category-box" class="category-box tab-select-box">
    	<div class="box1">
        	<div class="pd">
        	<?php $_from = $this->_var['catlist']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['c']):
?>
        	<div   to="c<?php echo $this->_var['c']['catid']; ?>" class="box1item   <?php if ($this->_var['c']['catid'] == get ( 'catid' ) || $this->_var['cat']['pid'] == $this->_var['c']['catid']): ?>active<?php endif; ?>"><?php echo $this->_var['c']['cname']; ?></div>
            
            <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?> 
            </div>
        </div>
        <div class="box2">
         <div class="pd">
        	<?php $_from = $this->_var['catlist']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['c']):
?>
            <div   v="<?php echo $this->_var['c']['catid']; ?>" class="box2item   c<?php echo $this->_var['c']['catid']; ?> <?php if ($this->_var['c']['catid'] == $this->_var['c']['catid']): ?>show<?php endif; ?> "><?php echo $this->_var['c']['cname']; ?></div>
            <?php $_from = $this->_var['c']['child']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'cc');if (count($_from)):
    foreach ($_from AS $this->_var['cc']):
?>
        	<div   v="<?php echo $this->_var['cc']['catid']; ?>" class="box2item   c<?php echo $this->_var['c']['catid']; ?> <?php if ($this->_var['cat']['catid'] == $this->_var['c']['catid']): ?>show<?php endif; ?> "><?php echo $this->_var['cc']['cname']; ?></div>
            <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
            <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?> 
            </div> 
        </div>
    </div>
    <div id="order-box" class="order-box tab-select-box">
    	<a class="item" v="default">智能排序</a>
        <a class="item" v="distance">距离最近</a>
        <a class="item" v="sold_num">销量最高</a>
        <a class="item" v="raty_grade">评价最好</a>
        
    
    </div>
    
    <div id="scarea-box" class="choice-box tab-select-box">
    	<a class="item" v="">全部</a>
        <?php $_from = $this->_var['sclist']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['c']):
?>
        <a class="item" v="<?php echo $this->_var['c']['sc_id']; ?>"><?php echo $this->_var['c']['title']; ?></a>
        <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?> 
    </div>
    
    <div id="choice-box" class="choice-box tab-select-box">
    	<a class="item" v="">全部</a>
    	<a class="item" v="cspf">超时赔付</a>
        
        <a class="item" v="isnew">新店</a>
    </div>
    
    <div class="flexslider">
      <?php $this->assign("ad1",M("ad")->listbyno("wap_shoplist_flash")); ?>
          <ul class="slides clearfix">
          <?php $_from = $this->_var['ad1']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['c']):
?>
            <li><a href="<?php echo $this->_var['c']['link1']; ?>"><img class="img" src="<?php echo images_site($this->_var['c']['imgurl']); ?>"></a> </li>
          <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>  
           
          </ul>
    </div>
     
      </div>
     <div class="shoplist" id="shoplist">
     	<?php $_from = $this->_var['list']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['c']):
?>
        
        <div class="item">
        	<a href="/index.php?m=shop&shopid=<?php echo $this->_var['c']['shopid']; ?>">
        	<div class="g-sd1"><img class="img" onerror="err_imgurl(this)" src="<?php echo images_site($this->_var['c']['logo']); ?>.100x100.jpg"></div>
            <div class="g-mn1">
            	<div class="g-mn1c">
                	<div class="title"> <?php echo $this->_var['c']['shopname']; ?> </div>
                    <div class="f2"> 
                    	<span>
                        	<span class="star star<?php echo intval($this->_var['c']['raty_grade']); ?>"></span>
                        </span>
                        <span>月销<?php echo $this->_var['c']['month_buy']; ?>份</span>
                    
                    </div>
                    <div class="f2"><?php echo $this->_var['c']['send_startprice']; ?>元起送 / <?php echo $this->_var['c']['send_time']; ?>分钟 / <?php echo $this->_var['c']['distance']; ?>米</div>
                     	
                </div>
            </div>
        	</a>
        </div>
         
        <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
     
     </div>
    
    <div id="loadmore" class="pullup">加载更多</div>
  </div>
</div>

<script type="text/html" id="shoplist-tpl">
	<%for(var i=0;i<list.length;i++){%>
	<div class="item">
        	<a href="/index.php?m=shop&shopid=<%=list[i].shopid%>">
        	<div class="g-sd1"><img class="img" onerror="err_imgurl(this)" src="<%=images_site(list[i].logo)%>.100x100.jpg"></div>
            <div class="g-mn1">
            	<div class="g-mn1c">
                	<div class="title"> <%=list[i].shopname%> </div>
                    <div class="f2"> 
                    	<span>
                        	<span class="star star<%=parseInt(list[i].raty_grade)%>"></span>
                        </span>
                        <span>月销<%=list[i].month_buy%>份</span>
                    
                    </div>
                    <div class="f2"><%=list[i].send_startprice%>元起送 / <%=list[i].send_time%>分钟 / <%=list[i].distance%>米</div>
                     	
                </div>
            </div>
        	</a>
        </div>
	<%}%>
</script>
<script src="<?php echo $this->_var['skins']; ?>js/jquery.flexslider-min.js"></script>
<script src="/plugin/jquery/template-native.js"></script>
 <script src="/plugin/skyweb/listload.js"></script>
<script>
var orderby='',catid=0,filter='',sc_id=0,first=false;; 
var per_page=<?php echo $this->_var['per_page']; ?>;
$(".flexslider").flexslider();
  
function loadShop(){
	if(per_page==0 && !first){		 
		return false; 
	 }
	get(SITE+'/index.php?m=shoplist&sc_id='+sc_id+'&catid='+catid+"&orderby="+orderby+"&filter="+filter+"&per_page="+per_page,function(data){
		per_page=data.data.per_page;
		if(per_page==0){
			//skyToast('没有数据了');
			$("#loadmore").hide();
		}else{
			$("#loadmore").show();
		}
		var html=template("shoplist-tpl",data.data);
		if(first){
			first=false;
			$("#shoplist").html(html);
			
		}else{
			$("#shoplist").append(html);
		}
	});
}

listload.loadid="#loadmore";
listload.showload(function(){
		loadShop();
 });

$(document).on("click","#tab-category",function(){
 
	$("#category-box").toggle().siblings(".tab-select-box").hide();
	
});

$(document).on("click",".box1item",function(e){
	e.preventDefault();
	
	$(".box1item").removeClass("active");
	$(this).addClass("active");
	$(".box2item").hide();
	$(".box2item."+$(this).attr("to")).css({display:"block"});
});

$(document).on("click",".box2item",function(){
	catid=$(this).attr("v");
	per_page=0;
	first=true;
	$(".box2item").removeClass("active");
	$(this).addClass("active");
	$("#tab-category .t").text($(this).text());
	loadShop();
	$("#category-box").hide();
});

$(document).on("click","#tab-scarea",function(){
 
	$("#scarea-box").toggle().siblings(".tab-select-box").hide();
	 
});

$(document).on("click","#scarea-box .item",function(){
	sc_id=$(this).attr("v");
	$("#scarea-box").hide();
	per_page=0;
	first=true;
	$("#scarea-box .item").removeClass("active");
	$(this).addClass("active");
	$("#tab-scarea .t").text($(this).text());
	loadShop();
});

$(document).on("click","#tab-order",function(){
 
 
	$("#order-box").toggle().siblings(".tab-select-box").hide();
	 
});




$(document).on("click","#order-box .item",function(){
	orderby=$(this).attr("v");
	$("#order-box").hide();
	per_page=0;
	first=true;
	$("#order-box .item").removeClass("active");
	$(this).addClass("active");
	$("#tab-order .t").text($(this).text());
	loadShop();
});

$(document).on("click","#tab-choice",function(){
	$("#choice-box").toggle().siblings(".tab-select-box").hide();
});

$(document).on("click","#choice-box .item",function(){
	filter=$(this).attr("v");
	$("#choice-box").hide();
	$("#tab-choice .t").text($(this).text());
	$("#choice-box .item").removeClass("active");
	$(this).addClass("active");
	per_page=0;
	first=true;
	loadShop();
});

$(".street_list_wrap .list li:odd").css("margin-left","2%");
imgResize(240,240);
		 $(window).resize(function(){
			 imgResize(240,240);
		 })
  </script>
  <?php $this->assign('botnav','shop'); ?>
 <?php echo $this->fetch('botnav.html'); ?>
 <?php echo $this->fetch('footer.html'); ?> 
</body>
</html>
